#!/bin/bash
DM_USER="{{ docker_dm_db_user }}"
DM_PASSWORD="{{ docker_dm_db_default_password }}"
DM_HOST="localhost"
DM_PORT="5237"

result=$(echo "SELECT 1 from JWAB.SYS_USER LIMIT 1;" | /opt/dmdbms/bin/disql $DM_USER/$DM_PASSWORD@$DM_HOST:$DM_PORT 2>/dev/null | grep -v "^SQL>" | grep -v "^-" | grep -v "^Server"|grep -v "^login"|grep -v "^LINEID"|grep -v "^used"|grep -v "V8"|grep -v "行号"|grep -v ms|grep -v ${DM_PORT}|cut -d ' ' -f1|tr -d '\n')

if [ "$result" = "1" ]; then
    echo "dameng database boot start ok"
    exit 0
else
    echo "dameng database booting..."
    exit 1
fi
